package com.zg.scf.service.impl;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zg.common.core.dao.BaseEntity;
import com.zg.common.core.dao.scf.CompanyApplyDao;
import com.zg.common.core.dao.scf.CompanyDao;
import com.zg.common.core.dao.scf.entity.Company;
import com.zg.scf.domain.req.company.CompanyPageReq;
import com.zg.scf.domain.vo.CompanyVo;
import com.zg.scf.enm.CompanyInfoConstants;
import com.zg.scf.mapper.CompanyInfoMapper;
import com.zg.scf.service.CompanyInfoService;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
@RequiredArgsConstructor
public class CompanyInfoServiceImpl implements CompanyInfoService {

    @Resource
    private CompanyDao companyDao;
    @Resource
    private CompanyInfoMapper companyInfoMapper;

    @Override
    public Boolean isAuth(Long id) {
        Company company = companyDao.getById(id);
        if (ObjectUtil.isNotEmpty(company)){
            return false;
        }else {
            String authStatus = company.getAuthStatus();
            if(CompanyInfoConstants.AuthStatusEnum.YES_STATUS.equals(authStatus)){
                return true;
            }else {
                return false;
            }
        }
    }

    @Override
    public IPage<CompanyVo> page(CompanyPageReq pageReq) {
        return companyInfoMapper.companyPage(new Page<CompanyVo>(pageReq.getPage(), pageReq.getPageSize()),pageReq);
    }
}
